package com.xiweicheng.test.proxy.resp.handler;

import java.io.IOException;
import java.net.HttpURLConnection;

import javax.servlet.http.HttpServletRequest;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LoginDispatchRespHandler extends DefaultRespHandler {

	@Override
	protected void setReqHeader(HttpServletRequest req, HttpURLConnection conn) {
		super.setReqHeader(req, conn);
		
		log.debug("登录api调用自定义headers...");
		
		conn.setRequestProperty("Host", "www.pingan.com.cn");
		conn.setRequestProperty("Origin", "https://www.pingan.com.cn");
		conn.setRequestProperty("Referer", "https://www.pingan.com.cn");
	}

	@Override
	protected void setReqBody(String body, HttpURLConnection conn) throws IOException {

		log.debug("Conn request body: {}", body);

		// body = StringUtils.replace(body, "loginShowTip=false", "loginShowTip=true");

		super.setReqBody(body, conn);
	}

}
